package br.com.clinica.supercao.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import br.com.rpteixeira.entity.AbstractEntity;
@Entity
@Table(name="PESSOA",schema="clinica")
@Inheritance(strategy=InheritanceType.JOINED)
public class Pessoa extends AbstractEntity {
	private static final long serialVersionUID = 1L;
	
	private String nome;
	private String cpf;
	private String email;
	private String endereco;
	private Integer telefone;
	private List<Animal> animais;
	private Integer celular;
	private String sexo;
	@Override
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PESSOA_GENERATOR")
	@SequenceGenerator(name = "PESSOA_GENERATOR", sequenceName = "clinica.pessoa_seq", initialValue = 1, allocationSize = 1)
	@Column(name="SEQ_PESSOA")
	public Integer getId() {
		return this.id;
	}
	@Column(name="DESC_NOME",length=255)
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	@Column(name="NUM_CPF",length=255)
	public String getCpf() {
		return cpf;
	}
	public void setCpf(String cpf) {
		this.cpf = cpf;
	}
	@Column(name="DESC_EMAIL",length=255)
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Column(name="DESC_ENDERECO",length=255)
	public String getEndereco() {
		return endereco;
	}
	public void setEndereco(String endereco) {
		this.endereco = endereco;
	}
	@OneToMany(mappedBy="dono",fetch=FetchType.LAZY)
	public List<Animal> getAnimais() {
		return animais;
	}
	public void setAnimais(List<Animal> animais) {
		this.animais = animais;
	}
	@Column(name="NUM_TELEFONE")
	public Integer getTelefone() {
		return telefone;
	}
	public void setTelefone(Integer telefone) {
		this.telefone = telefone;
	}
	@Column(name="NUM_CELULAR")
	public Integer getCelular() {
		return celular;
	}
	public void setCelular(Integer celular) {
		this.celular = celular;
	}
	@Column(name="SEXO_PESSOA")
	public String getSexo() {
		return sexo;
	}
	public void setSexo(String sexo) {
		this.sexo = sexo;
	}
	@Transient
	public boolean isPossuiAnimais(){
		return getAnimais()!=null|| getAnimais().isEmpty();
	}
}
